From: Huji Lee Date: Mon, 18 Sep 2017 01:10:27 +0000 (-0400) Subject: user: Unregister hooks that interfere with unit testing X-Git-Tag: 1.31.0-rc.0~1946^2 X-Git-Url: http://git.cyclocoop.org/%28%5B%5E/404?a=commitdiff_plain;h=b4592fb5c6a382f05f76bc246adde255c209023b;p=lhc%2Fweb%2Fwiklou.git user: Unregister hooks that interfere with unit testing testExecute_email() should unregister the hooks mailPasswordInternal and SpecialPasswordResetOnSubmit for proper unit testing. Bug: T176102 Change-Id: Id7403f57cc9d751ada85b611193c1d8f3503e713 --- diff --git a/tests/phpunit/includes/user/PasswordResetTest.php b/tests/phpunit/includes/user/PasswordResetTest.php index 53f02df69c..feae26a2dc 100644 --- a/tests/phpunit/includes/user/PasswordResetTest.php +++ b/tests/phpunit/includes/user/PasswordResetTest.php @@ -5,7 +5,7 @@ use MediaWiki\Auth\AuthManager; /** * @group Database */ -class PasswordResetTest extends PHPUnit_Framework_TestCase { +class PasswordResetTest extends MediaWikiTestCase { /** * @dataProvider provideIsAllowed */ @@ -150,6 +150,12 @@ class PasswordResetTest extends PHPUnit_Framework_TestCase { 'EnableEmail' => true, ] ); + // Unregister the hooks for proper unit testing + $this->mergeMwGlobalArrayValue( 'wgHooks', [ + 'mailPasswordInternal' => [], + 'SpecialPasswordResetOnSubmit' => [], + ] ); + $authManager = $this->getMockBuilder( AuthManager::class )->disableOriginalConstructor() ->getMock(); $authManager->expects( $this->any() )->method( 'allowsAuthenticationDataChange' )